import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //2+22+222+2222，a的值和加数个数n均从键盘获取
/*        Scanner num = new Scanner(System.in);
        double a = num.nextDouble();
        int n = num.nextInt();
        int sum = 0;
        double temp = a;
        for (int i = 1; i <= n ; i++) {
            sum += a;
            a = a + Math.pow(10, i) * temp;
        }
        System.out.println(sum);*/


        //将所有的五位数中的回文数打印输出，例如12321，个位与万位，十位与千位相同
        /*int a, b, c, d, e;
        for (int i = 10000; i < 100000; i++) {
            a = i / 10000;
            b = (i % 10000) / 1000;
            c = (i % 10000 % 1000) / 100;
            d = (i % 10000 % 1000 % 100) / 10;
            e = (i % 10000 % 1000 % 100) % 10;
            if (a == e && d == b) {
                System.out.println(i + " ");
            }
        }*/

        //国家的奖励
/*        double weight = 0.00001;
        double sum = 0;
        double temp = weight;
        for (int i = 1; i <= 64; i++) {
            sum += weight;
            weight = Math.pow(2, i) * temp;
        }
        System.out.println(sum);*/

/*        double sum=0;
        for (int i=0;i<64;i++){
            sum+=Math.pow(2,i);
        }
        System.out.println("sum="+sum/100000);*/

        //1!+2!+3!+4!+...+n!
/*        Scanner num = new Scanner(System.in);
        int n = num.nextInt();
        int sum = 0;
        int temp = 1;
        for (int i = 1; i <= n; i++) {
            temp = temp * i;
            sum += temp;
        }
        System.out.println(sum);*/

       /* Scanner num = new Scanner(System.in);
        int n = num.nextInt();*/

        //最简单的输出数
/*         for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2 * i + 1; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }*/

        //升级版的数，数在中间输出
        /*for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n - i; j++) {
                System.out.print(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++) {
                System.out.print("*");
            }
            System.out.println(" ");
        }

        for (int i=1;i<=n-1;i++){
            for (int j=1;j<=i;j++){
                System.out.print(" ");
            }
            for (int k=1;k<=-2*i+2*n-1;k++){
                System.out.print("*");
            }
            System.out.println(" ");
        }*/

        //有 1、2、3、4  四个数字，能组成多少个互不相同且无重复数字的三位数？都有哪些？
/*        int a, b, c;
        for (int i = 100; i < 1000; i++) {
            a = i / 100;
            b = i % 100 / 10;
            c = i % 100 % 10;
            if ((0 < a && a < 5) && (0 < b && b < 5) && (0 < c && c < 5)) {
                if (a != b && a != c && b != c) {
                    System.out.println(i);
                }
            }
        }*/

        /*
         * 编程找出 1000 以内的所有完数。
         * 一个数如果恰好等于它的因子之和，这个数就称为“完数”。例如 6 = 1＋2＋3。
         */
        for (int i = 2; i <= 1000; i++) {
            int sum = 0;
            for (int j = 1; j < i; j++) {
                if (i % j == 0) {
                    sum += j;
                }
            }
            if (i == sum) {
                System.out.println(i);
            }
        }
    }
}
